package com.iwhalecloud.citybrain.flow.platform.manager.application.utils;

import org.flowable.engine.common.api.variable.VariableContainer;
import org.flowable.engine.common.impl.el.ExpressionManager;
import org.flowable.engine.common.impl.el.VariableContainerWrapper;
import org.flowable.engine.common.impl.interceptor.Command;
import org.flowable.engine.common.impl.interceptor.CommandContext;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.util.CommandContextUtil;

/**
 * @author: liyang
 * @date: 2021/11/25 20:08
 */
public class ExpressionCmd implements Command<Object> {

    private String expression;

    private VariableContainer variableContainer;

    public ExpressionCmd(String expression, VariableContainer variableContainer) {
        this.expression = expression;
        this.variableContainer = variableContainer;
    }

    @Override
    public Object execute(CommandContext commandContext) {
        ExpressionManager expressionManager = CommandContextUtil.getProcessEngineConfiguration().getExpressionManager();
        return expressionManager.createExpression(expression).getValue(variableContainer);
    }
}
